<!--
 * @Description: 正常人群分布
 * @Author: Ronda
 * @Date: 2020-06-19 14:40:35
 * @LastEditors: 李洋洋
 * @LastEditTime: 2021-07-17 09:42:26
-->
<template>
  <div> <div id="map_container"></div></div>
</template>

<script>
export default {
  data() {
    return {};
  },
  computed: {},
  methods: {},
  created() {},
  mounted() {
    /* global BMapGL */

    /* global mapv */

    /* global mapvgl */

    /* global initMap */

    /* global whiteStyle */

    /* global purpleStyle */

    var map = initMap({
        tilt: 0,
        heading: 0,
        center: [105.348145,37.976416],
        zoom: 5,
        style: purpleStyle
    });

    // 创建九段线
    var pt = new BMapGL.Point(130.943495,22.781036);
    var myIcon = new BMapGL.Icon('http://120.53.125.221:8181/uploadimg/jiuduanxian.png', new BMapGL.Size(102, 150));
    var marker = new BMapGL.Marker(pt, {icon: myIcon, enableDragging: true});  // 创建标注
    map.addOverlay(marker);

    var view = new mapvgl.View({
        map: map
    });

    fetch('http://120.53.125.221:8181/uploadimg/chinalocation.json').then(rs => {
        return rs.json();
    }).then(rs => {
        var data1 = [];
        var data2 = [];
        var data3 = [];
        for (var i = 0; i < rs[0].length; i++) {
            var geoCoord = rs[0][i].geoCoord;
            data1.push({
                geometry: {
                    type: 'Point',
                    coordinates: geoCoord
                },
                properties: {
                    time: Math.random() * 100
                }
            });
        }

        for (var i = 0; i < rs[1].length; i++) {
            var geoCoord = rs[1][i].geoCoord;
            data2.push({
                geometry: {
                    type: 'Point',
                    coordinates: geoCoord
                },
                properties: {
                    time: Math.random() * 10
                }
            });
        }

        for (var i = 0; i < rs[2].length; i++) {
            var geoCoord = rs[2][i].geoCoord;
            data3.push({
                geometry: {
                    type: 'Point',
                    coordinates: geoCoord
                },
                properties: {
                    time: Math.random() * 10
                }
            });
        }

        view.addLayer(new mapvgl.PointLayer({
            blend: 'lighter',
            shape: 'circle',
            color: 'rgba(255, 77, 77, 0.8)', // 点图层1颜色
            data: data1,
            size: 1
        }));

        view.addLayer(new mapvgl.PointLayer({
            blend: 'lighter',
            shape: 'circle',
            color: 'rgba(255, 204, 0, 0.6)', // 点图层2颜色
            data: data2,
            size: 3
        }));

        view.addLayer(new mapvgl.PointLayer({
            blend: 'lighter',
            shape: 'circle',
            color: 'rgba(255, 255, 0, 0.6)', // 点图层3颜色
            data: data3,
            size: 4
        }));

        view.addLayer(new mapvgl.PointTripLayer({
            blend: 'lighter',
            shape: 'circle',
            startTime: 0,
            endTime: 100,
            step: 0.1,
            trailLength: 10,
            color: 'rgba(255, 255, 153, 0.5)', // 点动画图层颜色
            data: data1,
            size: 3
        }));
    });
  },
};
</script>
<style scoped>
  #map_container {
        width: 100%;
        height: 100vh;
        margin: 0;
    }
</style>